


	
	
<div class='buttons'>

</div>

	   <script type="text/javascript">

  jQuery(document).ready(function($) {
      //if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

      var stats;
      var camera, scene, renderer;
      var projector, plane, cube;
      var mouse2D, mouse3D, ray,
      rollOveredFace, isShiftDown = false,
      theta = 45, isCtrlDown = false;

      var rollOverMesh, rollOverMaterial;
      var cubeGeo, cubeMaterial;
      var i, intersector;
      var info;
      var stageWidth,stageHeight;
      var objects=[];
      var centerOffset;
      var rollOverMesh;
	  var stageSize;
	  var house;
	  var gid;
	  var cameraTarget;
	  var facilityInfo;
	  var gui, voxelConfig = {
				orthographicProjection: false
			};
	var voxelPosition = new THREE.Vector3(), tmpVec = new THREE.Vector3();
	
	var fov=100;
	var compass='b';
	var offsetCamera=new THREE.Vector3();
	var clock = new THREE.Clock();
	var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
	
	var curFacInfo=null,hostFacInfo=null;
	
	var cursorMesh/*临时用*/
      init();
      animate();
    
      function init() {
        //$('#dock').attr('float','left');
        //$('#dock').attr('top','30px');
        //$('#dock').attr('zIndex',100);
        //$('.stage').append($('#dock'));
        
        

        stageWidth=window.innerWidth;
        stageHeight=window.innerHeight;
		stageSize={width:stageWidth,height:stageHeight};
		    
		    // cameraTarget = new THREE.Vector3( 0, 0, 0 );
				// // camera = new THREE.Camera( stageSize.width, stageSize.height, 20, 1, 10000, -2000, 10000 );
				// var aspect = stageWidth / stageHeight;
				// camera = new THREE.Camera( 75, aspect, 1, 100000 );
				// camera.position.y = 800;
				
				var aspect = stageWidth / stageHeight;
				fov=100;
				camera = new THREE.PerspectiveCamera( fov, aspect, 1, 100000 );
				camera.position.z = 600;
				camera.position.x = 0;
				camera.position.y = 100;
				// camera.size=new THREE.Vector3(10,10,10);
				// camera.updateMatrix();
					

        lon=-90;
            controls = new THREE.FirstPersonControls( camera );
		        controls.lookSpeed = 0.0125;
		        controls.movementSpeed = 500;
		        controls.noFly = false;
		        controls.lookVertical = true;
		        controls.constrainVertical = false;
		        controls.verticalMin = 1.5;
		        controls.verticalMax = 2.0;
		        controls.lon = lon;
		        controls.freeze=true;

        scene = new THREE.Scene();

        // // roll-over helpers
// 
       // cursorGeo = new THREE.CubeGeometry( 50, 20, 50 );
       // cursorMaterial = new THREE.MeshBasicMaterial( { color: 0x123456, opacity: 0.5, transparent: true } );
       // cursorMesh = new THREE.Mesh( cursorGeo, cursorMaterial );
       // scene.add( cursorMesh );


        // cubes
        
        //cube2Geo = new THREE.CubeGeometry( 300, 300, 300 );
        //cube2Material = new THREE.MeshLambertMaterial( { color: 0x00ff80, ambient: 0x00ff80, shading: THREE.FlatShading, map: THREE.ImageUtils.loadTexture( "textures/square-outline-textured.png" ) } );
        //cube2Material.color.setHSV( 0.1, 0.7, 1.0 );
        //cube2Material.ambient = cube2Material.color;
        //cube2Mesh = new THREE.Mesh( cube2Geo, cube2Material );
        //cube2Mesh.position.set(300,150,300); 
        //scene.add(cube2Mesh);
        
        
        // picking

        projector = new THREE.Projector();

        // // grid
// 
        // // plane = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x999933, wireframe: true } ) );
        // // plane.rotation.x = - 90 * Math.PI / 180;
        // // plane.name="background";
        // // scene.addObject( plane );
        // planeGeo=new THREE.PlaneGeometry( 2000, 2000, 50, 50 );
        // planeGeo.computeBoundingBox();
		// plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 50, 50 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) );
		// //plane = new THREE.Mesh( new THREE.Planintersector.object.size 2000, 2000 , 200, 200));
		// // plane.rotation.x = - 90 * Math.PI / 180;
		// plane.name="background";
		// plane.size=planeGeo.boundingBox.max.subSelf(planeGeo.boundingBox.min);
		// scene.add( plane );
		
		planeGeo = new THREE.CubeGeometry( 2000, 2,2000 );
		planeMat=new THREE.MeshBasicMaterial( { color: 0xC0C0C0 } ) ;
		plane=addMesh( planeGeo, 1, 0, -1, 0, 0, 0, 0, planeMat,"background" );

        var cursorGeo = new THREE.CubeGeometry( 100, 100, 100 );
        cursorGeo.computeBoundingBox();
        var cursorMaterial = new THREE.MeshBasicMaterial( { color: 0xff00aa, opacity: 0.5, transparent: true } );
        cursorMesh =addMesh(cursorGeo, 1, camera.position.x, camera.position.y, camera.position.z, 0, 0, 0, cursorMaterial, 'cursor');
        //cursorMesh.visible=false;
        cursorMesh.name='cursor';
        mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
        centerOffset=new THREE.Vector3( 0, 0, 0);
        


		// Lights

        // var ambient = new THREE.AmbientLight( 0xffffff );
        // scene.add( ambient );

        // var directionalLight = new THREE.DirectionalLight( 0xffffff );
        // directionalLight.position.set( 0, 0, 100 ).normalize();
        // scene.add( directionalLight );
//         
        // var directionalLightZ2 = new THREE.DirectionalLight( 0xffffff );
        // directionalLightZ2.position.set( 0, 0, 0 ).normalize();
        // scene.add( directionalLightZ2 );      
//         
        // var directionalLightX = new THREE.DirectionalLight( 0xffffff );
        // directionalLightX.position.set( 100,0,0 ).normalize();
        // scene.add( directionalLightX );
// 
        // var directionalLightX2 = new THREE.DirectionalLight( 0xffffff );
        // directionalLightX2.position.set( -100,0,0 ).normalize();
        // scene.add( directionalLightX2 );
//         
        // var directionalLightY = new THREE.DirectionalLight( 0xffffff );
        // directionalLightY.position.set( 0,100,0 ).normalize();
        // scene.add( directionalLightY );
        
				// var ambient = new THREE.AmbientLight( 0x444444 );
				// scene.add( ambient );

				light = new THREE.SpotLight( 0xffffff,1.5);
				light.position.set( 0, 100, 0 );
				light.target.position.set( 0, -10, 0 );
// 
				light.castShadow = false;
// 
				light.shadowCameraNear = 70;
				light.shadowCameraFar = camera.far;
				light.shadowCameraFov = 5;
// 
				light.shadowCameraVisible = true;
// 
				light.shadowBias = 0.0001;
				light.shadowDarkness = 0;
// 
				light.shadowMapWidth = SHADOW_MAP_WIDTH;
				light.shadowMapHeight = SHADOW_MAP_HEIGHT;
// 
				scene.add( light );
				
				
								// LIGHTS

				var ambient = new THREE.AmbientLight( 0xaaaaaa );
				scene.add( ambient );

				// var directionalLight = new THREE.DirectionalLight( 0xffeedd );
				// directionalLight.position.set( 0, -70, 100 ).normalize();
				// scene.add( directionalLight );

    
        
				// //renderer = new THREE.WebGLRenderer( { clearColor: 0x000000, clearAlpha: 1,antialias: true, preserveDrawingBuffer : true } );
				// renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer : true } );
				
				renderer = new THREE.WebGLRenderer();
				// renderer.domElement.style.position = "relative";
				renderer.setSize( window.innerWidth, window.innerHeight );


        		$('.stage').append( $(renderer.domElement) );



		        stats = new Stats();
		        stats.domElement.style.position = 'absolute';
		        stats.domElement.style.top = '30px';
		        $('.stage').append( $(stats.domElement) );
        

				/*
				// add GUI
				gui = new DAT.GUI();
				gui.add(voxelConfig, 'orthographicProjection').onChange(function(){
				
					if ( voxelConfig.orthographicProjection ) {
						camera.toOrthographic();
						camera.position.x = 1000;
              camera.position.y = 707.106;
              camera.position.z = 1000;
						theta = 90;
					} else {
						camera.toPerspective();
						camera.position.y = 800;
					}
				
				});
				gui.close();
      */
        //$('.stage canvas').bind('mousemove',function(event){move(event);}); 
        $(this).bind('keydown',function(event){
							switch( event.keyCode ) {

					case 16: isShiftDown = !isShiftDown; break;
					case 17: isCtrlDown = !isCtrlDown; break;

				}
		});

      }

			function addMesh( geometry, scale, x, y, z, rx, ry, rz, material,type ) {

				geometry.computeBoundingBox();
				mesh = new THREE.Mesh( geometry, material );
				mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
				mesh.position.x = x;
				mesh.position.y = y;
				mesh.position.z = z;
				mesh.rotation.x = rx;
				mesh.rotation.y = ry;
				mesh.rotation.z = rz;
				mesh.overdraw = true;
				mesh.doubleSided = false;
				mesh.type=type;
				mesh.size=geometry.boundingBox.max.subSelf(geometry.boundingBox.min);
				mesh.updateMatrix();


				scene.add(mesh);
				
				return mesh;
			
			}
			
      //

      function animate() {

        requestAnimationFrame( animate );

        render();
        stats.update();

      }

      function render() {

				var delta = clock.getDelta();
				controls.around( delta );
        cursorMesh.position.copy(camera.position);
        cursorMesh.rotation.copy(camera.rotation);
        // cursorMesh.position.z=camera.position.z-10;
        cameraInsector();
				renderer.render( scene, camera );

      }

    buildHouse=function(hsId,roomStyles){
    	
    	house=new House(camera,scene);
    	// house.build(hsId,roomStyles);
		house.loadHouseStyle(hsId,roomStyles);
		 $('.stage canvas').bind('click',function(event){getFocus(event,plane);}); 
      
    };
    function cameraInsector(){
        var f_vector = new THREE.Vector3( 0, 0, -1 );
 		var b_vector = new THREE.Vector3( 0, 0, 1 );
        var l_vector = new THREE.Vector3( -1, 0, 0 );
        var r_vector = new THREE.Vector3( 1, 0, 0 );
        
        halfSize=10;
        var left = new THREE.Vector3( cursorMesh.position.x-halfSize, cursorMesh.position.y-halfSize, cursorMesh.position.z );
        var right = new THREE.Vector3( cursorMesh.position.x+halfSize, cursorMesh.position.y-halfSize, cursorMesh.position.z );
		var front = new THREE.Vector3( cursorMesh.position.x, cursorMesh.position.y-halfSize, cursorMesh.position.z+halfSize );
        var back = new THREE.Vector3( cursorMesh.position.x, cursorMesh.position.y-halfSize, cursorMesh.position.z-halfSize );

           // front
        if (controls.moveForward) {
          var left_ray = new THREE.Ray( left, f_vector );
          var left_intersects = left_ray.intersectObjects( scene.children );
          if ( left_intersects.length > 0 && left_intersects[0].distance < halfSize ) {
            cursorMesh.position.z = left_intersects[0].point.z+halfSize+1;
            controls.moveForwardFreeze=true;
            controls.freeze=true;
            camera.position.z= left_intersects[0].point.z+halfSize+1;
            console.warn("intersected on	"+left_intersects[0].object.name+" "+left_intersects[0].object.type+" "+left_intersects[0].object.description);
           
            //alert(left_intersects[0].point.z);
            
          }
          var right_ray = new THREE.Ray( right, f_vector );
          var right_intersects = right_ray.intersectObjects( scene.children );
          if ( right_intersects.length > 0 && right_intersects[0].distance < halfSize ) {
            cursorMesh.position.z = right_intersects[0].point.z+halfSize+1;
  			controls.freeze=true;
  			controls.moveForwardFreeze=true;
            console.warn("intersected on	"+right_intersects[0].object.name+" "+right_intersects[0].object.type+" "+right_intersects[0].object.description);
          }
        }
                // back
        if (controls.moveBackward) {
          var left_ray = new THREE.Ray( left, b_vector );
          var left_intersects = left_ray.intersectObjects( scene.children );
          if ( left_intersects.length > 0 && left_intersects[0].distance < halfSize ) {
          	controls.moveBackwardFreeze=true;
          	controls.freeze=true;
            cursorMesh.position.z = left_intersects[0].point.z-halfSize-1;
            console.warn("intersected on	"+left_intersects[0].object.name+" "+left_intersects[0].object.type+" "+left_intersects[0].object.description);
          }
          var right_ray = new THREE.Ray( right, b_vector );
          var right_intersects = right_ray.intersectObjects( scene.children );
          if ( right_intersects.length > 0 && right_intersects[0].distance < halfSize ) {
          	controls.moveBackwardFreeze=true;
          	controls.freeze=true;
            cursorMesh.position.z = right_intersects[0].point.z-halfSize-1;
            console.warn("intersected on	"+right_intersects[0].object.name+" "+right_intersects[0].object.type+" "+right_intersects[0].object.description);
          }
        }
        
                // right
        if (controls.moveRight) {
          var back_ray = new THREE.Ray( back, r_vector );
          var back_intersects = back_ray.intersectObjects( scene.children );
          if ( back_intersects.length > 0 && back_intersects[0].distance < halfSize ) {
            cursorMesh.position.x = back_intersects[0].point.x-halfSize-1;
            controls.moveRightFreeze=true;
          	controls.freeze=true;
          	console.warn("intersected on	"+back_intersects[0].object.name+" "+back_intersects[0].object.type+" "+back_intersects[0].object.description);
          }
          var front_ray = new THREE.Ray( front, r_vector );
          var front_intersects = front_ray.intersectObjects( scene.children );
          if ( front_intersects.length > 0 && front_intersects[0].distance < halfSize ) {
            cursorMesh.position.x = front_intersects[0].point.x-halfSize-1;
			controls.moveRightFreeze=true;
          	controls.freeze=true;
          	console.warn("intersected on	"+front_intersects[0].object.name+" "+front_intersects[0].object.type+" "+front_intersects[0].object.description);
          }
        }
        // left
        if (controls.moveLeft) {
          var back_ray = new THREE.Ray( back, l_vector );
          var back_intersects = back_ray.intersectObjects( scene.children );
          if ( back_intersects.length > 0 && back_intersects[0].distance < halfSize ) {
            cursorMesh.position.x = back_intersects[0].point.x+halfSize+1;
			controls.moveLeftFreeze=true;
          	controls.freeze=true;
          	console.warn("intersected on	"+back_intersects[0].object.name+" "+back_intersects[0].object.type+" "+back_intersects[0].object.description);
          }
          var front_ray = new THREE.Ray( front, l_vector );
          var front_intersects = front_ray.intersectObjects( scene.children );
          if ( front_intersects.length > 0 && front_intersects[0].distance < halfSize ) {
            cursorMesh.position.x = front_intersects[0].point.x+halfSize+1;
			controls.moveLeftFreeze=true;
          	controls.freeze=true;
          	console.warn("intersected on	"+front_intersects[0].object.name+" "+front_intersects[0].object.type+" "+front_intersects[0].object.description);
          }
        }
        
  };
	loadHouse=function(h){

		// for(i in objects){
			// scene.removeObject(objects[i]);
		// }
		// scene.add( plane );
		while(scene.getChildByName('fac')||scene.getChildByName('wall')||scene.getChildByName('floor')){
				scene.remove(scene.getChildByName('fac'));
				scene.remove(scene.getChildByName('wall'));
				scene.remove(scene.getChildByName('floor'));
		}
		
		house=new House(camera,scene);
		house.load(h);
		$('.stage canvas').bind('click',function(event){getFocus(event,plane);}); 
		// $('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
		// alert(h);
		
	};
    
	quoteMesh=function(goodsGeo,event){   
			event.preventDefault();
			hostFacInfo=curFacInfo;
			house.addFacility(goodsGeo,hostFacInfo);
			curFacInfo=house.houseGoodsInfo;

			showButtons(event);
			
			// facility.createMesh(goodsGeo,scene);

			$('.stage canvas').unbind('click');
			// showButtons(event);
			// $('.stage canvas').bind('mousemove',{stageSize:stageSize,plane:plane},move); 
			// $('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
      	}
			
			var move=function(event){
				event.preventDefault();
				scene.remove(cursorMesh);
				mouse2D.x = ( event.clientX / stageSize.width ) * 2 - 1;
				mouse2D.y = - ( event.clientY / stageSize.height ) * 2 + 1;
				if(house)
				//house.moveFacility(mouse2D);
			   house.moveFacilityOnHost(mouse2D,hostFacInfo);	
			};
      
      var getFocus=function(event){
        event.preventDefault();
    		mouse2D.x = ( event.clientX / stageSize.width ) * 2 - 1;
    		mouse2D.y = - ( event.clientY / stageSize.height ) * 2 + 1;
    		if(house.getFacility(mouse2D,plane)){
    			curFacInfo=house.houseGoodsInfo;
    			//curFacInfo.name='fac';
    			house.houseGoodsInfo=null;
    		    $('.stage canvas').unbind('click');
    		    showButtons(event);	
    		}

      };

		var locate=function(event){
        // facility.isCollided(event);
        if(house){

    				if(house.releaseFacility()){
    				    $('.stage canvas').unbind('mousemove');
		                $('.stage canvas').unbind('click');
		                $('.stage canvas').bind('click',function(event){getFocus(event,plane);}); 
    				};
    				//$('.stage canvas').bind('mousemove',function(event){move(event);}); 
    				
		    }
	};

  var rotate=function(event){
  	
      facility.rotate(event);
  };
			


	var saveHouse=function(saveHouseUrl){
		house?house.save(saveHouseUrl):alert("please load house style first");
		
	};
	
	


	
	$('#save').click(function(){
	 //alert(saveHouseUrl);
		saveHouse(saveHouseUrl);
	});
	
	$('#load').click(function(){
   //alert(loadHouseUrl);
    loadHouse(loadHouseUrl);
  });
			

/**
 * move Ctrl
 */
        $('.Move_f').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -44px");
        }).mousedown(function(){
            //alert('mousedown');
            controls.freeze=false;
            controls.moveForward = true;
            
            controls.moveRightFreeze=false;
			      controls.moveLeftFreeze=false;
			      controls.moveBackwardFreeze=false;

        });
        $('.Move_r').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -88px");
        }).mousedown(function(){
            controls.freeze=false;
            controls.moveRight = true;
            
            controls.moveForwardFreeze=false;
			      controls.moveLeftFreeze=false;
			      controls.moveBackwardFreeze=false;	
        });
        $('.Move_b').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -132px");
        }).mousedown(function(){
            controls.freeze=false;
            controls.moveBackward = true;
            
      			controls.moveRightFreeze=false;
      			controls.moveLeftFreeze=false;
      			controls.moveForwardFreeze=false;
			
        });
        $('.Move_l').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -176px");
        }).mousedown(function(){          
            controls.freeze=false;
            controls.moveLeft = true;
            
      			controls.moveRightFreeze=false;
      			controls.moveForwardFreeze=false;
      			controls.moveBackwardFreeze=false;
        });

        
        $('.rotate_l').mouseenter( function() {
        }).mousedown(function(){          
            controls.freeze=false;
            controls.rotateLeft = true;
        });

        $('.rotate_r').mouseenter( function() {
        }).mousedown(function(){          
            controls.freeze=false;
            controls.rotateRight = true;
        });
                
        $('.rotate').mouseup(function(){
            controls.freeze=true;
            
            controls.moveForward = false;
            controls.moveRight = false;
            controls.moveBackward = false;
            controls.moveLeft = false;
                        
            controls.rotateLeft = false;
            controls.rotateRight = false;
            
            controls.lookUp = false;
            controls.lookRight = false;
            controls.lookDown = false;
            controls.lookLeft = false;
            controls.constrainVertical = true;
        }); 
        
        
        $('.Look_u').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -44px");
        }).mousedown(function(){
            //alert('mousedown');
            controls.freeze=false;
            controls.lookUp = true;
        });
        $('.Look_r').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -88px");
        }).mousedown(function(){
            controls.freeze=false;
            controls.lookRight = true;
        });
        $('.Look_d').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -132px");
        }).mousedown(function(){
            controls.freeze=false;
            controls.lookDown = true;
        });
        $('.Look_l').mouseenter( function() {
           $('.BMap_stdMpPan').css('background-position',"0px -176px");
        }).mousedown(function(){          
            controls.freeze=false;
            controls.lookLeft = true;
        });
        
        $('.BMap_button').mouseleave( function() {
          $('.BMap_stdMpPan').css('background-position',"0px 0px");
        }).mouseup(function(){
            controls.freeze=true;
            
            controls.moveForward = false;
            controls.moveRight = false;
            controls.moveBackward = false;
            controls.moveLeft = false;
            
            controls.rotateLeft = false;
            controls.rotateRight = false;
            
            controls.lookUp = false;
            controls.lookRight = false;s
            controls.lookDown = false;
            controls.lookLeft = false;
            //controls.lon=-110;
            lon=controls.lon;
            
        });
             
        
        /**
         * coompass
         */
		var props = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '),
			prop,
			el = document.createElement('div');
		
		for(var i = 0, l = props.length; i < l; i++) {
			if(typeof el.style[props[i]] !== "undefined") {
				prop = props[i];
				break;
			}
		}
		document.getElementById('cube').style[prop] = "rotateX(-30deg) rotateY(-30deg) ";
		/*		//$('#cube').css(prop,"rotateX(-30deg) rotateY(-30deg) ");
		var xAngle = 0, yAngle = 0;
		$('body').keydown(function(evt) {
			switch(evt.keyCode) {
				case 37: // left
					yAngle -= 90;
					break;
				
				case 38: // up
					xAngle += 90;				
					break;
				
				case 39: // right
					yAngle += 90;
					break;
					
				case 40: // down
					xAngle -= 90;
					break;
			};
			 document.getElementById('cube').style[prop] = "rotateX("+xAngle+"deg) rotateY("+yAngle+"deg)";
			//$('#cube').css(prop,"rotateX("+xAngle+"deg) rotateY("+yAngle+"deg)");
		});	
		*/
		$('.face').click(function(evt) {
			switch($(this).attr('id')){
				case 'faceUp':
					xAngle=-120;
					yAngle=0;
					compass='u';
					break;
				case 'faceDown':
					xAngle=-300;
					compass='d';
					break;	
				case 'faceFront':
					xAngle=-30;
					yAngle=-210;
					controls.freeze=false;
					// controls.moveLeft = true;
					// controls.moveForward = true;
					
					compass='f';
					break;	
				case 'faceBack':
					xAngle=-30;
					yAngle=-30;
					compass='b';
					break;		
				case 'faceRight':
					xAngle=-30;
					yAngle=-120;
					compass='r';
					break;	
				case 'faceLeft':
					xAngle=-30;
					yAngle=-300;
					compass='l';
					break;	
			};
			
			document.getElementById('cube').style[prop] = "rotateX("+xAngle+"deg) rotateY("+yAngle+"deg)";
		});	

        /**
         * toolbar
         */
        $( "#slider-vertical" ).slider({
          orientation: "vertical",
          range: "min",
          min: 0,
          max: 100,
          value: fov,
          slide: function( event, ui ) {
           // $( "#amount" ).val( ui.value );
           //alert(ui.value);
           fov=100-ui.value;
          }
        });

        /**
         * popmenu
         */
var showButtons= function (event) {

	$('.stage canvas').unbind('mousemove');	
	$('.stage canvas').unbind('click');	
	// if(curFacInfo.name=='wall'){
		// $('"#dialog"').css({width:'100%',height:'100%',overflow:'hidden'}).append($('.house'))
		// .dialog({width:650,height:450});
	// }
	var diaOpt={width:200,height:250, title:curFacInfo.goodsName};
	
	//alert(curFacInfo.name);
	$('#dialog').show();
	  	$('.goodsName').html(curFacInfo.goodsName);
  		$('.description').html(curFacInfo.description);       
      console.warn(curFacInfo.parasitizedFace);
	if(curFacInfo.type=='wall'||curFacInfo.type=='floor'){
	  	$('.wallmenu').show();
    	$('.opmenu').hide();
    	$('#dialog').dialog(diaOpt);
	}
  else if(curFacInfo.type=='released'||curFacInfo.type=='fac'){
    $('.opmenu').show();
    $('.wallmenu').hide();
    $('#dialog').dialog(diaOpt);
  }

	
	$('.stage canvas').click(function(){
		$('#dialog').dialog( "close" );
		$('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
	});

  $("#move").click(function(){
    $('#dialog').dialog( "close" );
    hostFacInfo=curFacInfo;
    $('.stage canvas').bind('mousemove',{stageSize:stageSize,plane:plane},move);
    $('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
    
  });
  
  $('#picker').mouseup(function(){
     //house.paintWall($('#color').val(),null,0);
     house.paintWall($('#color').val(),curFacInfo.name,0);
     $('.stage canvas').bind('click',function(event){getFocus(event,plane);}); 
  });
  
  $('#wallpaper').click(function(){
  
          house.paintWall("wallpaper1.jpg",curFacInfo.name,1);
         // house.paintWall("wallpaper1.jpg",null,1);
           $('.stage canvas').bind('click',function(event){getFocus(event,plane);}); 
  });

//$('#furniture').html("<a class='dockitem' href='/room3/index.php?r=webgl/facility&amp;gTypeId=02001&amp;pageNo=1'>电视</a>");

  $('#furniture').click(function(){
    // var url=loadFacilityUrl+'&amp;gTypeId=02001&amp;pageNo=1'//+
    //'&amp;facePositionX='+curFacInfo.parasitizedFace.positionX+'&amp;facePositionY='+curFacInfo.parasitizedFace.positionY+'&amp;facePositionZ='+curFacInfo.parasitizedFace.positionZ+
    //'&amp;faceSizeX='+curFacInfo.parasitizedFace.sizeX+'&amp;facePositionY='+curFacInfo.parasitizedFace.sizeY+'&amp;facePositionZ='+curFacInfo.parasitizedFace.sizeZ;
  
    hostFacInfo=curFacInfo;
    //$('.dockitem').attr('href',url);
  });
                 
	};
		

});


		</script>
	
<div class='stage'>

</div>
<!--?php include  dirname(__FILE__).'/toolbar.php';?--> 
<?php include  dirname(__FILE__).'/moveCtrl.php';?>
<?php include  dirname(__FILE__).'/popmenu.php';?>
<div class='house'></div>